package cn.cloudplug.core.util;

import java.lang.reflect.Method;

/**
 * Created by pc on 2018/1/19.
 */

public class SNUtil {
    private static Method systemProperties_get = null;
    private static final String []propertys = {"ro.boot.serialno", "ro.serialno"};

    static String getAndroidOsSystemProperties(String key) {
        String ret;
        try {
            systemProperties_get = Class.forName("android.os.SystemProperties").getMethod("get", String.class);
            if ((ret = (String) systemProperties_get.invoke(null, key)) != null)
                return ret;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

        return "";
    }
    public static String getDevicesSn(){
        for (String key : propertys){
//          String v = android.os.SystemProperties.getConfiguration(key);
            String v = getAndroidOsSystemProperties(key);
            if(v!=null&&v.length()>0){
                return v;
            }
        }
        return null;
    }
}
